<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
${aier_doctype}
<html <s:property value="aier_html_xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<title><s:property value="ev_title" />
</title>
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<link rel="stylesheet" href="${aier_css_url}b.css" />
<link rel="stylesheet" type="text/css" href="${aier_css_url}jp/1.css" />
<link href="${aier_css_url}jq/jq.css" rel="Stylesheet" />
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}/ui.css" />
<link rel="stylesheet" href="${aier_css_url}comm/text.css" />
<link rel="stylesheet" href="${aier_css_url}admin/admin.css" />

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/1.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/afu.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/hh/ui.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/arrayList.js"></script>
<script type="text/javascript" src="${aier_js_url}jc/cj.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}comm/text.js"></script>
</head>
<script type="text/javascript"> 
$(document).ready(function(){
   	var myTable = document.getElementById("enUpDelDiv"); 
	myTable.style.display ="none";
});
</script>
<body style="background-color: #EEF2FB;">
    
    <div style="background-color: #EEF2FB;width: 100%;height: 700px;">
                    <div id="tabs">
                    <ul>
                        <li><a href="#tabs-1">创建门禁设备</a></li>
                    </ul>
                    <div id="tabs-1" style="height: 500px;">
                        <div class="d_content">
	                        <div class="d_scnOut">
			                    <div class="d_scname">
			                        <label for="txt_tName">设备sn:</label>
			                    </div>
			                    <div class="d_sctext">
			                        <input type="text" id="enSn">
			                    </div>
			                </div>
                            <div class="d_scnOut">
                                <div class="d_scname">
                                    <label for="txt_tName">描述:</label>
                                </div>
                                <div class="d_sctext">
                                    <input type="text" id="enDes">
                                </div>
                            </div>
                            <div class="d_scnOut">
                                <div class="d_scname">
                                    <label for="txt_tName">设备厂家:</label>
                                </div>
                                <div class="sel_region">
                                    <s:select list="es" id="enEqVe"></s:select>
                                </div>
                            </div>
                            <div style="margin-top: -120px;margin-left: 320px;">
			                    <div class="d_scnOut">
			                        <div class="d_scname">
			                            <label>状态:</label>
			                        </div>
			                        <div class="sel_region">
			                            <select id="enState"><option value=10>启用</option><option value=0>停用</option></select>
			                        </div>
			                    </div>
			                    <div class="d_scnOut">
			                        <div class="d_scname">
			                            <label>是否开启拍照:</label>
			                        </div>
			                        <div class="sel_region">
			                            <select id="enPho">
		                                    <option value=11>都拍照</option>
		                                    <option value=0>不拍照</option>
		                                    <option value=10>进门拍照</option>
		                                    <option value=1>出门拍照</option>
		                                </select>
			                        </div>
			                    </div>
			                </div>
			                <div style="margin-top: 0px;margin-left: 0px;">

			                    <button id="Ensure"
			                        onclick="enInsert()" value="确定"
			                        class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
			                        role="button" aria-disabled="false">
			                        <span class="ui-button-text">确定</span>
			                    </button>
			                </div>
                        
					<br>
					<table id="enUpDelDiv" width='90%' border='1' bordercolor='#a0c6e5' style='border-collapse:collapse;' class='tableSiz1'>
						<tr><td colspan=10 bgcolor='#CCFF00'>修改设备信息</td></tr><tr>
						<tr><td width="18%">设备sn</td><td width="18%">状态</td><td width="24%">描述</td><td width="24%">是否开启拍照</td><td width="24%">设备厂家</td><td width="16%">操作</td>
						</tr>
						<tr>
						   <td><input type="text" style="margin:0px;vertical-align:middle;"id="enUpDelSn"></td>
						   <td><select id="enUpDelState" style="width: 100px;">
								   <option value=10>启用</option>
								   <option value=0>停用</option>
							   </select>
						   </td>
						   <td><input type="text" style="margin:0px;vertical-align:middle;" id="enUpDelDes"></td>
						   <td>	<select id="enUpDelPho" style="width: 100px;">
									<option value=11>都拍照</option>
									<option value=0>不拍照</option>
									<option value=10>进门拍照</option>
									<option value=1>出门拍照</option>
								</select>
							</td>
						   <td><s:select list="es" id="enUpDelEqVe" style="width: 100px;"></s:select></td>
						   <td><button value="确定" id="enUpDelSure" onclick="updateD()">确定</button></td>
						</tr>
						<tr><td colspan="7"><input type="text" id="enUpDelEid" style="visibility:hidden"></td></tr>
					</table>
					<br>
					<table style="width:90%">
						<tr><td><div id="enDisDataDiv"></div></td></tr>
						<tr><td><div id=icCdate class="jqpage"></div></td></tr>
					</table>
					</div>
					</div>
					</div>

    </div>


</body>



<script type="text/javascript">
$("#tabs").tabs();
	function show(){
	 	var myTable= document.getElementById("enUpDelDiv"); 
	 	myTable.style.display ="block";
	}
	
	function hidden(){ 
		var myTable = document.getElementById("enUpDelDiv"); 
		myTable.style.display ="none";
	}

	//向数据库写入信息
	function enInsert() {
		var fun = function(data) {
			if (1 == data.s) {
				alert("保存成功");
			} else {
				alert("失败");
			}
		};
		exeAjax(ajaxUrl("${aier_url}zxadminjs/entr_entradd${aier_suffix}"),
				fun, {

					"sn" : $('#enSn').val(),
					"des" : $('#enDes').val(),
					"state" : $('#enState').val(),
					"vdstate" : $('#enPho').val(),
					"supplier" : $('#enEqVe').val(),

				});

	}
	//显示信息
	function enDisolayDatas(p) {
		var fun = function(data) {
			var temp = "<table width='100%' border='1' bordercolor='#a0c6e5' style='border-collapse:collapse;' class='tableSiz1'>"
					  +"<tr><td colspan=10 bgcolor='#CCFF00'>设备信息</td></tr><tr><td width='15%'>设备sn</td><td width='15%'>状态</td><td width='15%'>描述</td>"
					  +"<td width='20%'>是否开启拍照</td><td width='20%'>设备厂家</td><td colspan=2 width='30%'>操作</td></tr>";	
					  
			for ( var i = 0; i < data.enlist.length; i++) {
				var tsn = data.enlist[i];	
				if (tsn.vdstate == 11) {
					tsn.vdstate = "都拍照";
				} else if (tsn.vdstate == 0) {
					tsn.vdstate = "不拍照";
				} else if (tsn.vdstate == 10) {
					tsn.vdstate = "进门拍照";
				} else if (tsn.vdstate == 1) {
					tsn.vdstate = "出门拍照";
				}
				if (tsn.state == 10) {
					tsn.state = "启用";
				} else if (tsn.state == 0) {
					tsn.state = "停用";
				}
				temp += "<tr><td>"+tsn.sn+"</td><td>"+tsn.state+"</td><td>"+tsn.des+"</td><td>"+tsn.vdstate+"</td><td>"+data.es[tsn.supplier]
						+"</td><td><input type='button' class='recordsbut2' value='修改' onclick='updateDataDIV("+tsn.eid+")'/></td>"
						+"<td><input type='button' value='删除' class='recordsbut2' onclick='DeleteD("+tsn.eid+")'/></td></tr>";
			}

			$("#icCdate").pager({
				pagenumber : data.page,
				pagecount : data.page_count,
				buttonClickCallback : function(page) {
					enDisolayDatas(page);
				}
			});
			temp += "</table>";
			$('#enDisDataDiv').html(temp);

		};
		exeAjax(ajaxUrl("${aier_url}zxadminjs/entr_entrlist${aier_suffix}"),
				fun, {
					"page" : p,
				});

	}

	//修改
	function updateDataDIV(eid) {
		var fun = function(data) {
			$('#enUpDelEid').val(data.entranceDevice.eid);
			$('#enUpDelSn').val(data.entranceDevice.sn);
			$('#enUpDelDes').val(data.entranceDevice.des);
			$('#enUpDelState').val(data.entranceDevice.state);
			$('#enUpDelPho').val(data.entranceDevice.vdstate);
			$('#enUpDelEqVe').val(data.entranceDevice.supplier);
			$('#enUpDelDiv').show();

		};
		exeAjax(ajaxUrl("${aier_url}zxadminjs/entr_searchentr${aier_suffix}"),
				fun, {
					"eid" : eid
				});
	}

	function updateD() {
		hidden();
		var fun = function(data) {
			if(1==data.s){
				alert("修改成功");
			};
			enDisolayDatas(data.page);

		};
		exeAjax(ajaxUrl("${aier_url}zxadminjs/entr_entrupdate${aier_suffix}"),
				fun, {
					"eid" : $('#enUpDelEid').val(),
					"sn" : $('#enUpDelSn').val(),
					"des" : $('#enUpDelDes').val(),
					"state" : $('#enUpDelState').val(),
					"vdstate" : $('#enUpDelPho').val(),
					"supplier" : $('#enUpDelEqVe').val(),

				});
	}
	//删除
	function DeleteD(eid) {
		var fun = function(data) {
			if (data.s == 1) {
				enDisolayDatas(data.page);
			}
			;

		};
		exeAjax(ajaxUrl("${aier_url}zxadminjs/entr_entrdelete${aier_suffix}"),
				fun, {
					"eid" : eid

				});

	}

	enDisolayDatas();
</script>
</html>